import sys
sys.path.remove('/opt/ros/kinetic/lib/python2.7/dist-packages')
import cv2
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
from alexnet import AlexNet

img = cv2.imread('1.jpg')
cv2.imread('1.jpg')
# img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
# img = cv2.resize(img.astype(np.float32), (227, 227))
cv2.imshow('pic', img)
print(img)
# plt.figure()
# f = plt.figure()
# plt.imshow(img)
# plt.show()
# plt.axis('off')
cv2.waitKey(0)
cv2.destroyAllWindows()

x = tf.placeholder(tf.float32, [1, 227, 227, 3])
keep_prob = tf.placeholder(tf.float32)
model = AlexNet(x, keep_prob, 1000, [])
score = model.fc8
softmax = tf.nn.softmax(score)

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    model.load_initial_weights(sess)
    img = cv2.resize(img.astype(np.float32))
    img = img.reshape((1, 227, 227, 3))
    probs = sess.run(softmax, feed_dict={x: img, keep_prob: 1})
    print(probs)

